.TH std::ostreambuf_iterator 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::ostreambuf_iterator \- std::ostreambuf_iterator

.SH Synopsis
   Defined in header <iterator>
   template< class CharT, class Traits = std::char_traits<CharT> >

   class ostreambuf_iterator                                              \fI(until C++17)\fP

       : public std::iterator<std::output_iterator_tag, void, void,
   void, void>
   template< class CharT, class Traits = std::char_traits<CharT> >        \fI(since C++17)\fP
   class ostreambuf_iterator;

   std::ostreambuf_iterator is a single-pass LegacyOutputIterator that writes
   successive characters into the std::basic_streambuf object for which it was
   constructed. The actual write operation is performed when the iterator (whether
   dereferenced or not) is assigned to. Incrementing the std::ostreambuf_iterator is a
   no-op.

   In a typical implementation, the only data members of std::ostreambuf_iterator are a
   pointer to the associated std::basic_streambuf and a boolean flag indicating if the
   end of file condition has been reached.

.SH Member types

   Member type       Definition
   iterator_category std::output_iterator_tag
   value_type        void
   difference_type   void           \fI(until C++20)\fP
                     std::ptrdiff_t \fI(since C++20)\fP
   pointer           void
   reference         void
   char_type         CharT
   traits_type       Traits
   streambuf_type    std::basic_streambuf<CharT, Traits>
   ostream_type      std::basic_ostream<CharT, Traits>

   Member types iterator_category, value_type, difference_type, pointer
   and reference are required to be obtained by inheriting from           \fI(until C++17)\fP
   std::iterator<std::output_iterator_tag, void, void, void, void>.

.SH Member functions

   constructor           constructs a new ostreambuf_iterator
                         \fI(public member function)\fP
   destructor            destructs an ostreambuf_iterator
   (implicitly declared) \fI(public member function)\fP
   operator=             writes a character to the associated output sequence
                         \fI(public member function)\fP
   operator*             no-op
                         \fI(public member function)\fP
   operator++            no-op
   operator++(int)       \fI(public member function)\fP
   failed                tests if output failed
                         \fI(public member function)\fP

.SH Example


// Run this code

 #include <algorithm>
 #include <iostream>
 #include <iterator>
 #include <string>

 int main()
 {
     std::string s = "This is an example\\n";
     std::copy(s.begin(), s.end(), std::ostreambuf_iterator<char>(std::cout));
 }

.SH Output:

 This is an example

.SH See also

   istreambuf_iterator input iterator that reads from std::basic_streambuf
                       \fI(class template)\fP
   ostream_iterator    output iterator that writes to std::basic_ostream
                       \fI(class template)\fP
